<script>
	export default {
		onLaunch: function() {
			let app = this;
			uni.getSystemInfo({
				success: res => {
					if (res.platform == 'ios' || res.platform == 'mac') {
						app.globalData.isIos = true;
					}
					if (res.statusBarHeight < 20) {
						app.globalData.statusBarHeight = 20;
						return;
					}
					app.globalData.statusBarHeight = res.statusBarHeight;
					app.globalData.screenHeight = res.screenHeight;
				}
			});
			app.$core.onRequestComplete(function (ret, response) {
				if(ret && ret.code===401) {
					if(app.$core.getUserinfo()) {
					  app.$core.logout();
					  uni.navigateTo({url: '/pages/login/login'});
					  uni.showToast({title: '登录过期,请重新登录',icon:'none'});
					}
			   }
			});
			setTimeout(function () {
				  // app初始化完成后再执行
				  app.$core.get({url:'xilutour.common/init_config',data:{},loading:false,success:(ret)=>{
					app.globalData.config = ret.data.config;
				  }})
				  
				  //1.定位
				  app.$core.getLocation();
			},1);
			
		},
		globalData: {
			isIos: false,
			platformStatus: 1,
			statusBarHeight: 20,
			screenHeight:0,
			//小程序配置的接口请求域名，为项目部署的服务器路径
			appid: 'wxc63be8c009026ec4',
			// apiBaseUri: "http://xilutour.com/api",
			 apiBaseUri: "https://luoyang.vrprism.com/api",
			////前端上传图片补全域名，如oss的https://xxxx.oss-cn-shanghai.aliyuncs.com，或https://your.site.com
			storageBaseUri: "https://bucket.oss-cn-shanghai.aliyuncs.com",
		
			 //阿里OSS的上传路径
			uploadOssStatus: false,
			alioss: {endpoint:'https://bucket.oss-cn-shanghai.aliyuncs.com'},
			config:{
				logo:'',
				refund_reasons:[],
				apply_rule:''
			},
			Event: {
				CurrentCityChange: "currentCityChange",
				CurrentCityChange2: "currentCityChange2",
				loginOut: "loginOut",
			},
			defaultCity:{
				id: 184,
				name: '洛阳市'
			},
		},
		onShow: function(e) {
			if(e.query){
				if(e.query.scene){
					let scene = decodeURIComponent(e.query.scene);
					let options = {}
					for (var i = 0; i < scene.split('&').length;i++){
					    var arr = scene.split('&')[i].split('=');
					    options[arr[0]] = arr[1];
					}
					if(options.uid != 'undefined' && options.uid > 0){
						let a = {expire: 0,value: options.uid};
						try{
							uni.setStorageSync('puser_id' + this.globalData.appid, a);
						}catch(e){
							//TODO handle the exception
							console.log(e);
						}
						
					}
				}
				
			}
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import url('/static/css/global.css');
	// @import 'uni_modules/uview-ui/index.scss'
</style>